package com.topone.Utils.wx.builder.template;

import com.topone.Exception.FanZoneServiceException;
import com.topone.Utils.DaoUtils;
import com.topone.Utils.wx.builder.template.service.WxFanzoneTemplateMessageService;
import com.topone.dataObject.BaseEntity;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;


/**
 *
 * @author eddie
 */
@Service
public class WxTemplateMessageService {

    protected final static Logger LOG = LoggerFactory.getLogger(WxTemplateMessageService.class);

    public static interface WxTemplateDataBuilder {

        WxMpTemplateMessage build(BaseEntity entity);
    }


    private final WxFanzoneTemplateMessageService wxFanzoneTemplateMessageService = new WxFanzoneTemplateMessageService();


    public static WxMpTemplateData create(String keyword, String value) {
        return new WxMpTemplateData(keyword, value);
    }

    public static WxMpTemplateData create(String keyword, String value, String color) {
        return new WxMpTemplateData(keyword, value, color);
    }

    public static WxMpTemplateMessage throwInvalidArgumentObjectException(BaseEntity entity) {
        LOG.error("Invalid argument object type: {}", DaoUtils.toJson(entity));
        throw new FanZoneServiceException("参数类型错误, 不合法的咨询对象");
    }

    public WxTemplateDataBuilder getSubmitMessageBuilder(String messageType) {
            return wxFanzoneTemplateMessageService.getSubmitMessageBuilder(messageType);

    }

}
